<?php


namespace part16_StateMode\Code4;

/**
 * 晚间工作状态
 */
class EveningState extends State
{

    public function writeProgram($work)
    {
        // 如果完成任务，转入下班状态
        if ($work->getFinished()) {
            $work->setState(new RestState());
        } else {
            //没完成转入加班状态
            if ($work->getHour() < 21) {
                $work->setState(new OTState());
            } else {
                $work->setState(new SleepingState());
            }
        }
        $work->writeProgram();
    }
}